<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<div th:replace="common/header::header('个人信息')"></div>
<script>
    function get_img(f) {
        var rd = new FileReader();//创建文件读取对象
        var files = f.files[0];//获取file组件中的文件
        rd.readAsDataURL(files);文件读取装换为base64类型
        rd.onloadend = function(e) {
            //加载完毕之后获取结果赋值给img
            document.getElementById("imageShow").src = this.result;
            $("imageShow").show();
        }
    }
    function  changeFile() {
        $('#changeFile').show();
        $('#cBtn').hide();
    }
</script>
<body>
<div id="wrapper" class="row">
    <div th:replace="common/header::nav"></div>
    <div id="page-inner">
        <div class="row">
            <div class="col-md-6 col-md-offset-3">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        个人信息表
                    </div>
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-hover">
                                <thead>
                                <tr th:if="${session.user.perimage==null || session.user.perimage==''}">
                                    <th style="width:40%;">头像</th>
                                    <th>
                                        <form  class="form-inline" action="/erems/uploadUserPhoto" method="post" enctype="multipart/form-data">
                                            <div class="form-group">
                                            <input type="file" name="file" title=""/>
                                                <img src="" id="imageShow" style="display: none"/>
                                            <input type="submit" value="上传" class="btn btn-primary"/>
                                            </div>
                                        </form>
                                    </th>
                                </tr>
                                <tr th:unless="${session.user.perimage==null || session.user.perimage==''}">
                                    <th style="width:40%;">头像</th>
                                    <th>
                                        <img th:src="'/erems/show-image/'+${session.user.perimage}" alt="个人头像" style="width: 100px;"/>
                                        <form  id="changeFile" class="form-inline" action="/erems/uploadUserPhoto" method="post" enctype="multipart/form-data" style="display: none">
                                            <div class="form-group">
                                                <input type="file" name="file" title=""/>
                                                <input type="submit" value="上传" class="btn btn-primary"/>
                                            </div>
                                        </form>
                                        <button id="cBtn" type="button" onclick="changeFile()">更改</button>
                                    </th>
                                </tr>
                                </thead>
                                <tbody th:object="${session.user}">
                                <tr>
                                    <td>姓名</td>
                                    <td th:if="*{name}" th:text="*{name}">zrq</td>
                                    <td th:unless="*{name}" th:text="*{name}">无</td>
                                </tr>
                                <tr>
                                    <td>用户名</td>
                                    <td th:text="*{username}">zrq</td>
                                </tr>
                                <tr>
                                    <td>性别</td>
                                    <td th:if="*{sex}" th:text="*{sex}">男</td>
                                    <td th:unless="*{sex}" th:text="*{sex}">无</td>
                                </tr>
                                <tr>
                                    <td>邮箱</td>
                                    <td th:if="*{email}" th:text="*{email}">zrq@zrq.com</td>
                                    <td th:unless="*{email}" th:text="*{email}">无</td>
                                </tr>
                                <tr>
                                    <td>电话</td>
                                    <td th:if="*{phone}" th:text="*{phone}">phone</td>
                                    <td th:unless="*{phone}" th:text="*{phone}">无</td>
                                </tr>
                                <tr>
                                    <td>身份证号</td>
                                    <td th:if="*{idnumber}" th:text="*{idnumber}">idnumber</td>
                                    <td th:unless="*{idnumber}" th:text="*{idnumber}">无</td>
                                </tr>
                                <tr>
                                    <td>教育背景</td>
                                    <td th:if="*{eduback}" th:text="*{eduback}">eduback</td>
                                    <td th:unless="*{eduback}" th:text="*{eduback}">无</td>
                                </tr>
                                <tr>
                                    <td>地址</td>
                                    <td th:if="*{address}" th:text="*{address.province+address.city}">address</td>
                                    <td th:unless="*{address}" th:text="*{address}">无</td>
                                </tr>
                                <!--有待确认考试信息时显示该项-->
                                <tr th:if="${session.currentExam != null}">
                                    <td>当前信息待确认考试</td>
                                    <td th:text="${session.currentExam.name}"></td>
                                </tr>
                                </tbody>
                            </table>
                            <th:block th:if="${session.currentExam != null}">
                                <button class="btn btn-primary">
                                    <a th:href="'/erems/examinee/joinExam'" style="color:white;">确认</a>
                                </button>
                            </th:block>
                            <button class="btn btn-warning">
                                <a th:href="'/erems/'+${session.user.role==0?'admin':(session.user.role==1?'manager':'examinee')}+'/updateInfo'" style="color:white;">修改</a>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /. ROW  -->
    </div>
    <!-- /. PAGE INNER  -->
</div>
<!-- /. WRAPPER  -->

<div th:replace="common/footer"></div>
</body>
</html>